package org.benxiong.iplay.service;

import org.benxiong.iplay.util.GlobalVar;
import org.benxiong.iplay.util.LogX;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkListener extends BroadcastReceiver{

	@Override
	public void onReceive(Context context, Intent intent) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE ); 
	    NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); 
	    GlobalVar.isNetworkConnected = activeNetInfo == null? false : activeNetInfo.isConnected();
	    
	    LogX.print("NetWork changed: "+ GlobalVar.isNetworkConnected);
	}

}
